package com.gitee.feizns.quickstart.ding.talk.api.v10.yida.forms.instances;

import com.aliyun.dingtalkyida_1_0.Client;
import com.aliyun.dingtalkyida_1_0.models.BatchRemovalByFormInstanceIdListHeaders;
import com.aliyun.dingtalkyida_1_0.models.BatchRemovalByFormInstanceIdListRequest;
import com.aliyun.dingtalkyida_1_0.models.DeleteFormDataHeaders;
import com.aliyun.dingtalkyida_1_0.models.DeleteFormDataRequest;
import com.aliyun.teautil.models.RuntimeOptions;
import com.gitee.feizns.quickstart.ding.talk.client.Clients;
import lombok.SneakyThrows;
import org.jetbrains.annotations.NotNull;

/**
 * 批量删除
 * 批量创建表单实例（/v1.0/yida/forms/instances/batchRemove）
 * 接口路径：<a href="https://open.dingtalk.com/document/orgapp/delete-multiple-form-instances">批量删除表单实例（/v1.0/yida/forms/instances/batchRemove）</a>
 * @link <a href="https://open.dingtalk.com/document/orgapp/delete-multiple-form-instances">服务端API 宜搭应用开发 表单 批量删除表单实例</a>
 * @author feizns
 * @since 2025/1/14
 */
public class BatchRemove {

    /**
     * 根据表单实例编号删除表单实例数据
     * @param accessToken {@link String}
     * @param req {@link DeleteFormDataRequest}
     */
    @SneakyThrows
    public static void execute(@NotNull String accessToken,
                                       @NotNull BatchRemovalByFormInstanceIdListRequest req) {
        Client client = Clients.get(Client.class);
        client.batchRemovalByFormInstanceIdListWithOptions(req, headers(accessToken), new RuntimeOptions());
    }

    /**
     * 请求头
     * @param accessToken 访问凭据
     * @return {@link DeleteFormDataHeaders}
     */
    public static BatchRemovalByFormInstanceIdListHeaders headers(String accessToken) {
        BatchRemovalByFormInstanceIdListHeaders headers = new BatchRemovalByFormInstanceIdListHeaders();
        headers.xAcsDingtalkAccessToken = accessToken;
        return headers;
    }

}
